<!--开启页面选项卡后，显示为选项卡标题-->
<title>Banner</title>

<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a><cite>运维管理</cite></a>
    <a><cite>下载中心</cite></a>
  </div>
</div>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-card-body">
      <table id="table_download" lay-filter="table_download"></table>
    </div>
  </div>
</div>

<script type="text/html" id="tpl_status">
  {{# if (d.status == 0) { }}
  <span>进行中</span>
  {{# } else { }}
  <span class="layui-font-green">已完成</span>
  {{# } }}
</script>

<script type="text/html" id="tpl_upload_status">
  {{# if (d.status == 0) { }}
  <span class="layui-font-red">上传中</span>
  {{# } else {}}
    {{# if (d.up_status == 1) { }}
    <span class="layui-font-green">成功</span>
    {{# } else { }}
    <span class="layui-font-red">失败</span>
    {{# } }}
  {{# } }}
</script>

<script type="text/html" id="tpl_url">
  {{# if (d.status == 0) { }}
    -
  {{# } else { }}
  <a target="_blank" style="text-decoration: underline;color:blue;" href="{{d.url}}">下载</a>
  {{# } }}
</script>

<script type="text/html" id="tpl_user">
  {{d.users.username}}
</script>

<script>
  layui.use(['table', 'form'], function () {
    let $ = layui.$
      , table = layui.table

    let resourceUrl = 'admin/downloads'
      , defaultWhere = {}

    // 列表查询
    table.render({
      elem: '#table_download'
      , url: resourceUrl
      // , where: defaultWhere
      // , page: true
      , cols: [[
         {title: 'ID', field: 'id', width: 80}
        , {title: '下载用户', templet:'#tpl_user', width: 140}
        , {title: '文件名称', field: 'name', width: 360}
        , {title: '下载链接', templet:'#tpl_url' ,  width: 120}
        , {title: '下载状态', templet: '#tpl_status', width: 120}
        , {title: '上传状态', templet: '#tpl_upload_status', width: 120}
        , {title: '创建时间', field: 'created_at', width: 250}
      ]]
    });

  })
</script>

